/*
 * @Author: szx
 * @Date: 2022-03-23 15:17:51
 * @LastEditTime: 2022-03-23 15:17:52
 * @Description: 
 * @FilePath: \leetcode\500-599\509\509_2.js
 */
var fib = function (n) {
    if (n <= 1) return n;
    let dp0 = 0,
        dp1 = 1,
        res = 1;
    for (let i = 2; i <= n; i++) {
        res = dp0 + dp1;
        dp0 = dp1;
        dp1 = res;
    }
    return res;
};